import java.awt.Color;
import java.awt.Graphics2D;


public class Laser
{
	public int offsetX = 0;
	public int offsetY = 0;
	double rotation = 0;
	double length = 0;
	Game game;
	Color color;
	
	public Laser(Game game)
	{
		this.game = game;
	}
	
	public void updatePosition(Game game, double mouseX, double mouseY)
	{
		rotation = Math.atan((mouseY - 300)/(mouseX - 400));
		if (mouseX < 400)
		{
			rotation =  rotation - Math.toRadians(180);
		}
		length = Math.sqrt(Math.pow(mouseX - 400, 2) + Math.pow(mouseY - 300, 2)) - 25;
	}
	
	
	public void update()
	{
		offsetX = game.player.x + game.player.sprite.frameWidth / 4;
		offsetY = game.player.y + game.player.sprite.height / 3;
	}
	
	public void draw(Graphics2D g)
	{
		if (game.leftClick || game.rightClick)
		{
			if (game.leftClick)
			{
				g.setColor(Color.BLUE);
			}
			if (game.rightClick)
			{
				g.setColor(Color.RED);
			}
			g.translate(offsetX, offsetY);
			g.rotate (rotation);
		//	g.fillRect(game.player.sprite.frameWidth, 0, (int)length, 10);
			g.translate(-offsetX, -offsetY);	
			g.rotate (-rotation);
		}
	}
}
